package com.yingsheng.bi.hks.service.stores;

import com.yingsheng.bi.hks.bo.StoresBo;
import com.yingsheng.bi.hks.dto.Stores.*;
import com.yingsheng.bi.hks.mapping.StoresMgmtMappings;
import com.yingsheng.bi.hks.repository.dao.po.Stores;
import com.yingsheng.bi.hks.repository.dao.service.StoresDaoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class StoresMgmtService {

    @Autowired
    private StoresDaoService storesDaoService;

    /**
     * 收件信息新增
     * @param req
     * @return
     */
    public StoresAddRes add(StoresAddReq req) {
        Stores stores = StoresMgmtMappings.INSTANCE.addReq2po(req);
        storesDaoService.insert(stores);
        return new StoresAddRes();
    }

    public StoresModRes mod(StoresModReq req) {
        Stores stores = StoresMgmtMappings.INSTANCE.addReq2po(req);
        storesDaoService.updateById(stores);
        return new StoresModRes();
    }

    public StoresQryRes qry(StoresQryReq req) {
        List<Stores> list = storesDaoService.query(req);
        List<StoresBo> addrList = StoresMgmtMappings.INSTANCE.storesList2boList(list);
        StoresQryRes res = new StoresQryRes();
        res.setStoresBoList(addrList);
        return res;
    }

    public StoresDelRes del(StoresDelReq req) {
        storesDaoService.del(req.getId());
        StoresDelRes res = new StoresDelRes();
        return res;
    }
}
